/*-------------------------------------------------------------------------------------------------------------------------------------------
Program: Table3_descriptive_variables_v3.do
Comments: This program produces the summary statistics of the demographic variables of the subjects.
----------------------------------------------------------------------------------------------------------------------------------------*/
*version Stata/SE 17.0

clear all
set more off
macro drop _all

cd "/Volumes/GoogleDrive/My Drive/Documents/JMP/Work/Tables/tables_replication" 

use 				"merged_v0.2_replication.dta" , clear
drop if fine==10 /*Keeps only the main sessions*/
******Demographic Variables**************
gen percent_fem = female*100
gen percent_HC  = HC*100
gen percent_employed = work*100
gen percent_hindu = hindu*100
gen percent_christian = christian*100
gen percent_muslim = muslim*100

label var  percent_fem      "Female(\%)"
label var  percent_HC			"High Caste(\%)"
label var  percent_employed			"Employed(\%)"
label var  age			"Age"
label var  educ			"Years of education"
label var  hh_inc		"Monthly HH Income (in Rupees)"
label var  earnings	    "Earnings(in Rupees)"
label var  percent_hindu "Hindus(\%)"
label var percent_christian "Christians(\%)"
label var percent_muslim "Muslims(\%)"

************Comprehension Questions***************
gen rule0 = (rule==0)
forvalues i = 1(1)3 {
forvalues j = 1(1)2 {

replace comp`i'_`j' = 100*comp`i'_`j'
}
}
replace comp4_1 = 100*comp4_1

label var  comp1_1		"How many 20 rupees notes are given to you?"
label var  comp2_1		"What color envelope will you use to send money to your counterpart?"
label var  comp3_1		"Will your counterpart know your name?"
label var 	comp4_1		"Will you and your counterpart get real money in exchange for the experimental currency?"
label var  comp1_2      "If someone sent 40 rupees, will she have to pay a fine of 15 rupees?"
label var  comp2_2      "What is Payoff if Amount Sent < Rule?"
label var  comp3_2      "What is Payoff if Amount Sent >= Rule?"

forvalues i = 1(1)4 {
replace comp`i'_1 = 0 if comp`i'_1 ==.	
}
forvalues i = 1(1)3 {
	replace comp`i'_2 = 0 if comp`i'_2 ==. & rule0==0
}
	 
					

eststo 	clear 
qui estpost 	sum		 percent_fem  	percent_HC 		percent_employed 	   ///
						 age			educ	 		hh_inc		  ///
						 percent_hindu	percent_christian   percent_muslim		///
						 earnings					///
						 comp1_1 		comp2_1 	///
						 comp3_1 		comp4_1		///
						 comp1_2 		comp2_2 	///
						 comp3_2

esttab using "Table3_ParticipantCharacteristics/Table3_unformatted.tex",  ///
				cells((mean (fmt(1)) sd (fmt(1))))  label replace ///
				nofloat 

exit
